package com.smritimap.demo.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

public class ArrowView extends View {

    private Paint mPaint;

    public ArrowView(Context context) {
        super(context);
        init();
    }

    public ArrowView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        mPaint = new Paint();
        mPaint.setColor(Color.BLACK);
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setAntiAlias(true);
        mPaint.setStrokeWidth(5);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        int width = getWidth();
        int height = getHeight();

        Path path = new Path();
        path.moveTo(width / 2, 0);
        path.lineTo(width, height / 2);
        path.lineTo(width / 2, height);
        path.lineTo(0, height / 2);
        path.close();

        canvas.drawPath(path, mPaint);
    }
}